#ifndef CBINARY_H_
#define CBINARY_H_

#include <cstring>
#include <fstream>
#include "../model/ccolor.h"

/**
 * CBinary - class reading/writing basic data types from/into binary files
 * @author Josef Smolka
 * @author Michal Rost
 * @date 18.07.2007
 */
class CBinary : public CObject {
public:
  CBinary() {}
  static unsigned int writeChar(ostream &fh, const char &num);
  static unsigned int writeShort(ostream &fh, const short &num);
  static unsigned int writeInt(ostream &fh, const int &num);
  static unsigned int writeUChar(ostream &fh, const unsigned char &num);
  static unsigned int writeUShort(ostream &fh, const unsigned short &num);
  static unsigned int writeUInt(ostream &fh, const unsigned int &num);
  static unsigned int writeFloat(ostream &fh, const float &num);
  static unsigned int writeDouble(ostream &fh, const double &num);
  static unsigned int writeBool(ostream &fh, const bool &val);
  static unsigned int writeTIndex(ostream &fh, const TIndex &num);
  static unsigned int writeString(ostream &fh, const string &str);
  static unsigned int writeCColor(ostream &fh, const CColor &c);
  static unsigned int writeBuffer(ostream &fh, const char* buf, unsigned int s);
  static unsigned int readChar(istream &fh, char &num);
  static unsigned int readShort(istream &fh, short &num);
  static unsigned int readInt(istream &fh, int &num);
  static unsigned int readUChar(istream &fh, unsigned char &num);
  static unsigned int readUShort(istream &fh, unsigned short &num);
  static unsigned int readUInt(istream &fh, unsigned int &num);
  static unsigned int readDouble(istream &fh, double &num);
  static unsigned int readFloat(istream &fh, float &num);
  static unsigned int readBool(istream &fh, bool &val);
  static unsigned int readTIndex(istream &fh, TIndex &num);
  static unsigned int readString(istream &fh, string& str);
  static unsigned int readPChar(istream &fh, string &str);
  static unsigned int readCColor(istream &fh, CColor &c);
  static unsigned int readBuffer(istream &fh, char* buf, unsigned int s);
  static string getClassName() {
    return "CBinary";
  }
};

#endif
